package com.imooc.business.core.executor.query.base.chart;//package com.imooc.business.core.executor.query.base.chart;
//
//import cn.mashang.report.modules.query.business.constant.GraphFlag;
//import cn.mashang.report.modules.query.business.constant.OrganType;
//import cn.mashang.report.modules.query.business.constant.RealType;
//import cn.mashang.report.modules.query.helper.ChartType;
//import cn.mashang.report.modules.query.infra.repository.designer.base.ReportChartResultRespository;
//import cn.mashang.report.modules.query.infra.repository.designer.request.SupportTypeRequest;
//import cn.mashang.report.modules.query.infra.repository.designer.request.TableExecRequest;
//import cn.mashang.report.modules.query.request.QueryExectRequest;
//import cn.mashang.vxiao.datadict.modules.user.group.GroupType;
//import cn.mashang.vxiao.modules.group.Group;
//import cn.mashang.vxiao.modules.group.IGroupService;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.dubbo.config.annotation.DubboReference;
//import org.springframework.stereotype.Repository;
//
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @Description: 群组榜单
// * @Author guyuefeng
// * @Date: 2022-10-20 10:25
// */
//@Repository
//public class ReportRealChartRankGroupResultRespository extends ReportChartResultRespository<Group,String> {
//
//    @DubboReference(check = false)
//    private IGroupService groupService;
//
//    @Override
//    protected List<Group> getOrganList(TableExecRequest request) {
//        Group group = request.getGroup();
//        List<Group> cgroups = groupService.listGroups(group.getParentId(), Arrays.asList(GroupType.ORDINARY, GroupType.CLASS, GroupType.COURSE_GROUP));
//        List<Group> groups = new ArrayList<>();
//        groups.add(group);
//        if (CollectionUtils.isNotEmpty(cgroups)) {
//            groups.addAll(cgroups.stream().sorted(Comparator.comparing(a -> a.getType())).collect(Collectors.toList()));
//        }
//        //排除当前群组设置为示范数据的群组
//        judgeCurrentGroupDemonstrateFlag(groups, null, false, request.getAppId());
//        return groups;
//    }
//
//    /**
//     * 获取指标数据
//     * @author: guyuefeng
//     * @date: 2022/10/19 16:45
//     */
//    @Override
//    protected Map<Object, Map<String, Object>> getDataMap(TableExecRequest request, List<Group> groups){
//        Map<Object, Map<String, Object>> groupMap = execQuery(QueryExectRequest.builder().
//                        groupIds(groups.stream().map(Group::getGroupId).collect(Collectors.toList())).build()
//                , request.getStartDate(), request.getEndDate(), request.getTimeType(),
//                request.getRuleSign(), request.getIndexSigns(), request.getPageSize(), request.getOffset());
//        return groupMap;
//    }
//
//    @Override
//    protected Boolean supportRun(ChartType chartType) {
//        return ChartType.CHART_LIST.equals(chartType);
//    }
//
//    @Override
//    protected String getName(Group group) {
//        return group.getName();
//    }
//
//    @Override
//    protected String getOrganId(Group group) {
//        return group.getGroupId();
//    }
//
//    @Override
//    protected String getOrganPhoto(Group organ) {
//        return organ.getLogo();
//    }
//
//    @Override
//    public Boolean supportType(SupportTypeRequest supportTypeRequest) {
//        return OrganType.GROUP.equals(supportTypeRequest.getOrganType()) &&
//                RealType.REAL.equals(supportTypeRequest.getRealType()) &&
//                GraphFlag.CHART.equals(supportTypeRequest.getGraphFlag());
//    }
//}
